package com.zhb.cloud.utils;

import java.io.Serializable;

import lombok.Data;

@Data
public class Result implements Serializable {
	private static final long serialVersionUID = -2779817544295899804L;

	private int code;

	private String info;

	// 通用的错误码
	public static Result SUCCESS = new Result(200, "success");
	public static Result SERVER_ERROR = new Result(500, "服务端异常");
	public static Result BIND_ERROR = new Result(400, "参数校验异常：%s");

	private Result() {
	}

	private Result(int code, String info) {
		this.code = code;
		this.info = info;
	}

	public Result fillArgs(Object... args) {
		int code = this.code;
		String message = String.format(this.info, args);
		return new Result(code, message);
	}
}
